{% extends "base.html" %}
{% load i18n %}
{% load icons %}

{% block title %}{% trans "Interface" %} - {{ iface }}{% endblock %}

{% block page_heading %}{% trans "Interface" %}: {{ iface }}{% endblock page_heading %}

{% block content %}
<div class="page-wrapper">
    <!--block content-->
    <div class="page-header d-print-none">
        <div class="container-xl">
            <div class="row g-2 align-items-center">
                <div class="col">
                    <div class="page-pretitle">
                        Interface
                    </div>
                    <h2 class="page-title">
                        {{ compute.name }}
                    </h2>
                </div>
            </div>
        </div>
    </div>

    <div class="page-body">
        <div class="container-xl">
            <div class="card">
                <div class="card-header">
                    <ul class="nav nav-tabs card-header-tabs">
                        <li class="nav-item">
                        <a class="nav-link" href="{% url 'overview' compute.id %}">
                            <span>{% icon 'dashboard' %}&nbsp;&nbsp;{% trans "Overview" %}</span>
                        </a>
                        </li>
                        <li class="nav-item">
                        <a class="nav-link" href="{% url 'instances' compute.id %}">
                            <span>{% icon 'server' %}&nbsp;&nbsp;{% trans "Instances" %}</span>
                        </a>
                        </li>
                        <li class="nav-item">
                        <a class="nav-link" href="{% url 'storages' compute.id %}">
                            <span>{% icon 'hdd-o' %}&nbsp;&nbsp;{% trans "Storages" %}</span>
                        </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'networks' compute.id %}">
                                <span>{% icon 'sitemap' %}&nbsp;&nbsp;{% trans "Networks" %}</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link active" href="#">
                                <span class="text-azure">{% icon 'wifi' %}&nbsp;&nbsp;{% trans "Interfaces" %}</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'nwfilters' compute.id %}">
                                <span>{% icon 'filter' %}&nbsp;&nbsp;{% trans "NWFilters" %}</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'virtsecrets' compute.id %}">
                                <span>{% icon 'key' %}&nbsp;&nbsp;{% trans "Secrets" %}</span>
                            </a>
                        </li>
                        <li class="nav-item ms-auto">
                            {% include 'create_iface_block.html' %}
                        </li>
                    </ul>
                </div>
                <div class="card-body">
                    <p class="text-muted">
                        <div class="row">
                            <dl class="ms-3 row">
                                <dt class="col-4">{% trans "Interface" %}</dt>
                                <dd class="col-8"><strong>{{ iface }}</strong></dd>
                                <dt class="col-4">{% trans "IPv4" %} ({% if ipv4 == None %}{% trans 'None' %}{% else %}{{ ipv4_type }}{% endif %})</dt>
                                <dd class="col-8">{{ ipv4 }}</dd>
                                <dt class="col-4">{% trans "IPv6" %} ({% if ipv6 == None %}{% trans 'None' %}{% else %}{{ ipv6_type }}{% endif %})</dt>
                                <dd class="col-8">{{ ipv6 }}</dd>
                                <dt class="col-4">{% trans "MAC" %}</dt>
                                <dd class="col-8">{{ mac }}</dd>
                                <dt class="col-4">{% trans "Interface Type" %}</dt>
                                <dd class="col-8">{{ itype }}</dd>
                                {% if itype == 'bridge' %}
                                    <dt class="col-4">{% trans "Bridge Device" %}</dt>
                                    <dd class="col-8">{{ bridge }}</dd>
                                {% endif %}
                                <dt class="col-4">{% trans "Boot Mode" %}</dt>
                                <dd class="col-8">{{ start_mode }}</dd>
                                <dt class="col-4">{% trans "State" %}</dt>
                                <dd class="col-8">
                                    <form action="" method="post" role="form" aria-label="Interface start/stop/delete form">{% csrf_token %}
                                        {% if state == 0 %}
                                            <input type="submit" class="btn btn-sm btn-outline-secondary" name="start" value="False">
                                            <input type="submit" class="btn btn-sm btn-outline-danger" name="delete" value="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')">
                                        {% else %}
                                            <input type="submit" class="btn btn-sm btn-outline-success" name="stop" value="True" onclick="return confirm('{% trans "Are you sure?" %}')">
                                        {% endif %}
                                    </form>
                                </dd>
                            </dl>                            
                        </div>
                    </p>
                </div>
                {% if itype == 'bridge' %}
                    <div class="card-body">
                        <p class="text-muted">
                            <div class="row">
                                <div class="col-12">
                                    <div class="card">
                                        <div class="ribbon bg-teal">{% trans 'Slaves' %}</div>
                                        
                                        <div class="card-body">
                                            <p class="text-muted">
                                                <div class="col-12">
                                                    <table class="table table-bordered">
                                                        <thead>
                                                        <tr>
                                                            <th scope="col">{% trans 'MAC' %}</th>
                                                            <th scope="col">{% trans 'Name' %}</th>
                                                            <th scope="col">{% trans 'Type' %}</th>
                                                            <th scope="col">{% trans 'Speed' %}</th>
                                                            <th scope="col">{% trans 'State' %}</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        {% for iface in slave_ifaces %}
                                                            <tr>
                                                                <td>{{ iface.mac }}</td>
                                                                <td>{{ iface.name }}</td>
                                                                <td>{{ iface.type }}</td>
                                                                <td>{{ iface.speed }}</td>
                                                                <td>{{ iface.state }}</td>
                                                            </tr>
                                                        {% endfor %}
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </p>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </p>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>

    

{% endblock %}